package org.example.api.goods.goods.enums;

import lombok.Getter;

@Getter
public enum GoodsTypeEnum {
  /**
   * 实体商品
   */
  PHYSICAL_GOODS("1","实体商品"),
  /**
   * 虚拟商品
   */
  VIRTUAL_GOODS("2","虚拟商品");

  final String code;
  final String desc;

  GoodsTypeEnum(String code, String desc) {
    this.code = code;
    this.desc = desc;
  }

  // 根据code获取枚举
  public static GoodsTypeEnum getByCode(String code) {
    for (GoodsTypeEnum goodsTypeEnum : GoodsTypeEnum.values()) {
      if (goodsTypeEnum.getCode().equals(code)) {
        return goodsTypeEnum;
      }
    }
    return null;
  }
}
